%PUT BANANAS!;

%GLOBAL CWD; %LET CWD = %SUBSTR(%SYSGET(SAS_EXECFILEPATH), 1, %EVAL(%LENGTH(%SYSGET(SAS_EXECFILEPATH)) - %LENGTH(%SYSGET(SAS_EXECFILENAME)) - 1));
%INCLUDE "&CWD\TOOLS.SAS";

/* SET ELI & CLUSTER */
%LET ELI = FK021;
%LET CLUSTER = 01A;

/* IDENTIFYING HANDLE */
%LET COM = &ELI._&CLUSTER.;

/* ITEM-SPECIFIC RIGHT HAND SIDE VARIABLES */
%LET RHS = 
    C1 C2 D99SP F1 F2 G1 G2 G3 G4 G5 G6 MNAMT MNAMTSQ   
    ;

%LET STYR = 0201;
%LET FIRSTPER = 20&STYR.;
%LET LASTPER = 200709;
%LET STDUM = D&STYR.;
%LET RHYRS = D0202 -- D0709;

%LET NSPER = %COUNTMONTHS(&FIRSTPER, &LASTPER);
%LET NVEC = %EVAL(&NSPER + %COUNTWORDS(&RHS));

/* DEFINE ITEM-SPECIFIC PRICE EDITS */
%MACRO EDITS;   
    IF A="A1"; * REGULAR YELLOW BANANAS;
    IF FULLSAMP_EFFPR_WOTX=>30 THEN DELETE;
%MEND;

/* DEFINE ITEM-SPECIFIC DUMMIES */
%MACRO VARS;
    
    A1=(A="A1"); A2=(A="A2"); A3=(A="A3"); A4=(A="A4"); 
    A99SP=(A="A99");
    ARRAY AARRAY (5) A1-A4 A99SP;
        DO COUNT=1 TO 5;
        IF A="" THEN AARRAY(COUNT)=.;
    END;

    ; 
    B1=(B="B1"); B2=(B="B2");
    ARRAY BARRAY (2) B1-B2 ;
        DO COUNT=1 TO 2;
        IF B="" THEN BARRAY(COUNT)=.;
    END;

    C1=(C="C1"); C2=(C="C2"); C3=(C="C3");
    ARRAY CARRAY (3) C1-C3;
        DO COUNT=1 TO 3;
        IF C="" THEN CARRAY(COUNT)=.;
    END;

    D99SP=(D="D99"); 
    E99SP=(E="E99"); 

    F1=(F="F1"); F2=(F="F2"); F3=(F="F3"); 
    ARRAY FARRAY (3) F1-F3;
        DO COUNT=1 TO 3;
        IF F="" THEN FARRAY(COUNT)=.;
    END;

    G1=(G="G1"); G2=(G="G2"); G3=(G="G3"); G4=(G="G4");
    if find(G99,'**********','i') then G5=1;else G5=0;
    if find(G99,'**********','i') then G6=1;else G6=0;
    if find(G99,'**********','i') then G6=1;
    G99SP=(G="G99");
    ARRAY GARRAY (7) G1-G6 G99SP;
        DO COUNT=1 TO 7;
        IF G="" THEN GARRAY(COUNT)=.;
    END;

    *ELIMINATE QUOTES WITH MISSING SPEC VARIABLES;
    *INCLUDE APPROPRIATE LIST OF SPEC VARIABLES HERE AND ELSEWHERE;
    *MODIFY SIZE OF SPECARRAY AS NEEDED TO NUMBER OF YOUR SPEC VARIABLES PLUS 5;
    *;
    ARRAY SPECARRAY (28)
        A1 A2 A3 A4 A99SP B1 B2 C1 C2 C3
        D99SP E99SP F1 F2 F3 G1 G2 G3 G4 G5 
        G6 G99SP
        DISCDEP--OTHSTORE;
    DO COUNT=1 TO 28;
        IF SPECARRAY(COUNT)=. THEN DELETE;
    END;

%MEND;

LIBNAME IN "&CWD\DATA";
LIBNAME OUT "&CWD\DATA";


FILENAME OUTLOGS "&CWD\OUTPUT\LOGINDEXES.XLS";
FILENAME OUTCONTS "&CWD\OUTPUT\LOGCONTRIBS.XLS";
FILENAME OUTDISCS "&CWD\OUTPUT\DISCOUNTS.XLS";
FILENAME OUTPCTLS "&CWD\OUTPUT\PCTLS.XLS";

%INCLUDE "&CWD\TABLESTOBUILD.SAS";

